﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewsUI.aspx.cs" Inherits="Demo.Web.NewsUI" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>三层架构拓展Demo</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <center style="width: 1000px; height: auto; background-color: #EDF7B0; margin-left: 150px;
            margin-top: 50px;">
            <asp:GridView runat="server" ID="gvNews" AutoGenerateColumns="False" EnableViewState="False" AllowPaging="true"
                OnRowCancelingEdit="gvNews_RowCancelingEdit" OnRowUpdating="gvNews_RowUpdating" PageSize="5"
                OnRowDataBound="gvNews_RowDataBound" OnRowEditing="gvNews_RowEditing" OnRowCommand="gvNews_RowCommand" OnPageIndexChanging="gvNews_PageIndexChanging">
                <AlternatingRowStyle BackColor="White" />
                <HeaderStyle BackColor="Orange" Font-Bold="True" ForeColor="White" />
                <PagerSettings FirstPageText="首页" LastPageText="末页" Mode="NextPreviousFirstLast"
                    NextPageText="下一页" PreviousPageText="上一页" />
                <PagerStyle BackColor="#999999" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#E3EAEB" />
                <EmptyDataTemplate>
                    <h1 style="color: Navy; border-width: 1px;">
                        无数据
                    </h1>
                </EmptyDataTemplate>
                <Columns>
                    <asp:TemplateField HeaderText="序号">
                        <ItemTemplate>
                            <%#Container.DataItemIndex+1 %>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" Width="5%" />
                        <ItemStyle HorizontalAlign="Center" Width="5%" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="新闻标题">
                        <EditItemTemplate>
                            <asp:TextBox ID="txtTitle" runat="server" Text='<%# Bind("newsTitle") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" Width="15%" />
                        <ItemStyle HorizontalAlign="Center" Width="15%" />
                        <ItemTemplate>
                            <%# Eval("newsTitle") %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="新闻内容">
                        <ItemTemplate>
                            <%# Eval("newsContext") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtContext" runat="server" Text='<%# Eval("newsContext") %>' TextMode="MultiLine"
                                Columns="50" Rows="4"></asp:TextBox>
                        </EditItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" Width="45%" />
                        <ItemStyle HorizontalAlign="Center" Width="45%" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="发布时间">
                        <ItemTemplate>
                            <%#Eval("NewsDate","{0:yyyy-MM-dd}") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtNewsDate" runat="server" Text='<%# Eval("NewsDate","{0:yyyy-MM-dd}")%>'></asp:TextBox>
                        </EditItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" Width="10%" />
                        <ItemStyle HorizontalAlign="Center" Width="10%" />
                    </asp:TemplateField>
                    <asp:CommandField ShowEditButton="True" HeaderText="操作" ButtonType="Button">
                        <HeaderStyle HorizontalAlign="Center" Width="13%" />
                        <ItemStyle HorizontalAlign="Center" Width="13%" />
                    </asp:CommandField>
                    <asp:TemplateField HeaderText="删除">
                        <HeaderStyle HorizontalAlign="Center" Width="7%" />
                        <ItemStyle HorizontalAlign="Center" Width="7%" />
                        <ItemTemplate>
                            <asp:Button ID="btnDelete" runat="server" Text="删除" CommandArgument='<%#Eval("NewsID") %>'
                                CommandName="myDelete" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <br />
            <asp:TextBox ID="txtNewsTitle" runat="server" Width="400px"></asp:TextBox>
            &nbsp;<span style="color: red; font-size: 20px;">*</span>
            <br />
            <asp:TextBox ID="txtNewsContext" runat="server" TextMode="MultiLine" Columns="80"
                Rows="10"></asp:TextBox>
            &nbsp;<span style="color: red; font-size: 20px;">*</span>
            <br />
            <asp:Button ID="btnAddNews" runat="server" Text="添加新闻" OnClick="btnAddNews_Click" />
        </center>
    </div>
    </form>
</body>
</html>
